import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [
  { path: '/', redirect: '/login' },
  { path: '/login', name: 'Login', component: ()=>import('../views/Login.vue')},
  {
    path: '/home', component: () => import('../views/Home.vue'),
    children: [
      { path: '/home', redirect: '/home/bookquery'},
      { path: 'bookquery', name: 'BookQuery', component: () => import('../components/BookQuery.vue')},
      { path: 'bookmanage', name: 'BookManage', component: () => import('../components/BookManage.vue')},
      { path: 'user', name: 'User', component: () => import('../components/User.vue')},
      { path: 'reader', name: 'Reader', component: () => import('../components/Reader.vue') },
      { path: 'borrow', name: 'Borrow', component: () => import('../components/Borrow.vue')},
      { path: 'borrowbooks/:bookId', name: 'BorrowBooks', component: () => import('../components/Borrowbooks.vue')},
      { path: 'backbooks/:bookId', name: 'BackBooks', component: () => import('../components/BackBooks.vue')},
    ]
  }
]

const router = createRouter({
  history: createWebHashHistory(process.env.BASE_URL),
  routes
})

export default router
